<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<script type="text/javascript" src="../../inc/ctx.jsp"></script>
<script type="text/javascript" src="../js/g.js"></script>
<script type="text/javascript" src="http://cdn.uuola.cn/js/formvalid.js" charset="utf-8"></script>
<script type="text/javascript" src="../js/channeltype.js"></script>
<link href="../css/com.css" type="text/css" rel="stylesheet"/>
<style>
    body{width:420px;height:150px;}
    #panel{width:400px;}
    #panel table{background:#fff;}
</style>
</head>
<body>

<div id="panel">
<form id="add_cat_frm" name="add_cat_frm">
    <input type="hidden" name="rid" id="rid" value="" />
    <input type="hidden" name="ctp" id="ctp" value="" />
    <input type="hidden" name="infotype" id="infotype" value="" />
  <table>
    <tr>
      <td width="10%" class="r">分类名称</td>
      <td width="26%">
        <input name="cname" type="text" id="cname" tabindex="1" maxlength="60" valid="required" errmsg="分类名称不能为空!" />* </td>
      <td width="13%">&nbsp;</td>
    </tr>
    <tr>
      <td class="r">是否开放</td>
      <td><select name="isopen" id="isopen" tabindex="2">
        <option value="1">开放</option>
        <option value="0">关闭</option>
      </select></td>
      <td>&nbsp;</td>
      </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input name="submitBtn" type="button" class="button medium orange" id="submitBtn" tabindex="7" value="添加" onClick="CAT.submit();" /></td>
      <td>&nbsp;</td>
      </tr>
  </table>
 </form>
</div>

    
    
<script type="text/javascript">
   var CAT={
       init:function(){
           $('#rid').val(ut.get('rid'));
           $('#ctp').val(ut.get('ctp'));
           $('#infotype').val(ut.get('infotype')); 
       },
       submit:function(){
     var $rb=$('#submitBtn');
     if(!va.title($('#cname').val())){
        ut.m('分类名称不符合要求,请不要使用特殊字符.');
        return; 
     }
 if(validator(ut.e('add_cat_frm'))){
     $rb.attr('disabled','disabled');
     $.post('../app/catalogs/make.shtm',$('#add_cat_frm').serialize(),function(x){
         var r = $.trim(x);
       if(r=='ok'){
           ut.m('添加分类成功!');
            var ctp = ut.get('ctp');
            var ca = ctp.substring(0, ctp.length-1).split('-');
            var gocid = '0';
            if(ca.length>=2){
            gocid = ca[ca.length-2];
            }
            window.parent.window.CAT.list(gocid);
            window.parent.window.TxBox.closeWinpop();
       }else{
           ut.m('添加失败!'+r);
           $rb.removeAttr('disabled');
       }
     });
 }   
       }
   };  
   
CAT.init();
</script>
</body>
</html>
